1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 |
<?php
#*********************************************************************
# Description:
# sasql_fetch_assoc() returns an associative array of strings
# representing the fetched row in a result set. The key of the array
# references the result set's column name. It returns FALSE if there
# are no more rows in the result set.
#
# This code sample shows how to execute a SELECT statement and
# print each row of the result set by referencing the column name.
#
#*********************************************************************
# Connect using the default user ID and password
$conn = sasql_connect ( "UID=DBA;PWD=sql" ) ;
# Check connection
if ( sasql_errorcode ( ) ) {
printf ( "Connect failed: %s \n " , sasql_error ( ) ) ;
exit ( ) ;
}
$query = "SELECT Surname, Phone FROM Employees ORDER by EmployeeID" ;
if ( $result = sasql_query ( $conn , $query ) ) {
# Fetch associative array
while ( $row = sasql_fetch_assoc ( $result ) ) {
# Print columns "Surname" and "Phone"
printf ( "%s (%s) \n " , $row [ "Surname" ] , $row [ "Phone" ] ) ;
}
# Free result set
sasql_free_result ( $result ) ;
}
# Close connection
sasql_close ( $conn ) ;
?> |
Copyright 2011 iAnywhere Solutions, Inc. All rights reserved. This sample
code is provided AS IS, without warranty or liability of any kind.
|